﻿using System;

namespace Batman.Jianbei.Chatroom
{
    public class ChatroomModule : AbpModule
    {
        public override void PreInitialize()
        {
            ForumInterceptorRegister.Initialize(IocManager.IocContainer.Kernel);

            // ABP的DbContext配置在这边 不要在startup AddDbContext 否则会出现501网关错误
            var connectionString = AspNetConfiguration.GetConnectionString("Default");
            Configuration.Modules.AbpEfCore().AddDbContext<JianbeiForumDbContext2>(options =>
            {
                options.DbContextOptions.UseMySql(connectionString);
            });

            var mongoConnectionString = AspNetConfiguration.GetConnectionString("Mongo");
            IocManager.Register<MongoClient>(DependencyLifeStyle.Singleton);
            IocManager.Resolve<MongoClient>(new { connectionString = mongoConnectionString });


        }
    }
}
